# -*- coding=utf-8-*-
"""
@File:memory_selection
@Author:Created by Han X.Y
@Date:on 2021/8/6 15:16 
"""

class Node:
    """
    定义树节点
    """
    def __init__(self,value=None,left=None,right=None):
        self.value=value
        self.left=left#左子树
        self.right=right#右子树


    def print(self):
        """
        默认以层次遍历打印该二叉树
        Returns:

        """
        stack = [self]
        res=[]
        while stack:
            # temp = stack.pop(0)
            temp = stack.pop(0)
            if temp.left:
                stack.append(temp.left)
            if temp.right:
                stack.append(temp.right)
            res.append(temp.value)
        return res


if __name__=='__main__':
    root=Node('1',Node('2',Node("3"),Node('4')),Node('2',right=Node('4',Node('3'))))
    tmp=root.print()
    print(tmp)

